import 'dart:ui';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:liuxlcommon/view/lxl_widget.dart';
import 'package:liuxlcommon/view/my_box.dart';
import 'package:liuxlcommon/view/my_style.dart';
import 'package:ladder_cash/config/super_theme.dart';

import '../../../Global.dart';
import '../../../gen/assets.gen.dart';
import '../../../generated/l10n.dart';
import 'decoration_bg.dart';
import 'liner_text.dart';

Widget commonBtn(String text,
    {required Function callback,
    String? img,
    bool isShowRight = false,
    double? fontSize,
      FontWeight fontWeight = FontWeight.w800}) {
  return InkWell(
    onTap: () {
      callback();
    },
    child: Container(
      alignment: Alignment.center,
      decoration: BoxDecoration(
        image: DecorationImage(
          image: AssetImage(img ?? Assets.splash.splash9527btn.path),
          fit: BoxFit.fill,
        ),
      ),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          textBorder(text,
              fontsize: fontSize ?? 20.sp,
              color: Colors.white,
              borderColor: Colors.black,
              fontWeight: fontWeight),
          if (isShowRight)
            Padding(
              padding: EdgeInsets.only(left: 10.w),
              child: Image.asset(
                Assets.home.home9528Arrow.path,
                width: 15.w,
                height: 15.w,
                fit: BoxFit.fill,
              ),
            )
        ],
      ),
    ),
  );
}

Widget myBtn(String text,
    {required Function callback,
    Color bgColor = SuperTheme.btnPrimary,
    double radius = 50.0,
    double? fontSize,
    Widget? widget}) {
  return InkWell(
    onTap: () {
      callback();
    },
    child: Container(
      alignment: Alignment.center,
      decoration: BoxDecoration(
        color: bgColor,
        borderRadius: BorderRadius.all(
          Radius.circular(radius),
        ),
      ),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisSize: MainAxisSize.min,
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          widget ?? Text(""),
          Text(
            text,
            style: TextStyle(
                fontWeight: FontWeight.w800,
                fontFamily: 'Regular',
                color: Colors.black,
                height: 1.0,
                fontSize: fontSize ?? 12.sp),
          ),
        ],
      ),
    ),
  );
}

/// 中等字体
Widget middleFont(String text,
    {Color color = SuperTheme.blc333,
    FontWeight fontWeight = FontWeight.w500,
    String fontFamily = 'Regular',
    Color borderColor = Colors.white,
    TextAlign textAlign = TextAlign.center,
    double? fontsize}) {
  return Text(
    text,
    textAlign: textAlign, //
    style: TextStyle(
        fontWeight: fontWeight,
        fontFamily: fontFamily,
        color: color,
        height: 1.0,
        fontSize: fontsize ?? 16.sp),
  );
}

Widget textBorder(String text,
    {Color color = SuperTheme.blc333,
    FontWeight fontWeight = FontWeight.w500,
    String fontFamily = 'Regular',
    Color borderColor = Colors.white,
    TextAlign textAlign = TextAlign.center,
    double? fontsize}) {
  return Stack(
    children: <Widget>[
      // Stroked text as border.
      Text(
        text,
        textAlign: textAlign,
        style: TextStyle(
          fontWeight: fontWeight,
          fontFamily: fontFamily,
          fontSize: fontsize ?? 16.sp,
          foreground: Paint()
            ..style = PaintingStyle.stroke
            ..strokeWidth = 2
            ..color = borderColor,
        ),
      ),
      // Solid text as fill.
      Text(
        text,
        textAlign: textAlign,
        style: TextStyle(
          fontWeight: fontWeight,
          fontFamily: fontFamily,
          fontSize: fontsize ?? 16.sp,
          color: color,
        ),
      ),
    ],
  );
}

/// 顶部status bar
Widget getTabBar({required String title,  Function? callback,bool isShowRight = false}) {
  return LContainer(
    onTap: () => {
      if(callback==null || isShowRight == false){

      }else{

        callback()
      }
    },
    lStyle: LStyle(
        width: Global.width,
        color: Colors.red,
        padding:
            EdgeInsets.only(top: Global.statusH, left: 25.w, right: 25.w, bottom: 20.w)),
    child: Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        isShowRight? LImage.easy(Assets.login.arrowRight.path, 16.w, 9.w) :SizedBox(width: 16.w,),
        getLinerText(title, endColor: SuperTheme.secondPrimary),
        SizedBox(width: 16.w),
      ],
    ),
  );
}

/// 带圆角的Container

getRoundContainer(){

}

getTitleTop(){
  return Container(
    alignment: Alignment.center,
    padding: EdgeInsets.all(12.w),
    margin: EdgeInsets.symmetric(horizontal: 12.w,vertical: 12.w),
    height: 76.w,
    decoration: BoxDecoration(
        image: getDecorationBg(Assets.cer.cerTextBg.path)),
    child: middleFont(S.current.protectPrivacy),
  );
}
